package com.zte.purchase.control;


import com.zte.purchase.pojo.PurchaseCBrand;
import com.zte.purchase.service.impl.PurchaseImpl;
import com.zte.util.PageModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/brand")
public class BrandAction {

    @Autowired
    private PurchaseImpl purchase;

    /**
     * 查找品牌信息
     * @param brand
     * @return
     */
    @ResponseBody
    @RequestMapping("/selectbrand")
    private PageModel<PurchaseCBrand> selectbrand(PurchaseCBrand brand, PageModel<PurchaseCBrand> pageModel, HttpSession session){
        PageModel<PurchaseCBrand> selectbrand = purchase.selectbrand(brand, pageModel);
        return selectbrand;
    }

    /**
     * 点击恢复/注销改变品牌状态
     * @param brand
     */
    @ResponseBody
    @RequestMapping("/updateBrandStatus")
    private int updateBrandStatus(PurchaseCBrand brand){
        int i = purchase.updateBrandStatus(brand);
        return i;
    }

    /**
     * 增加品牌
     * @param brand
     * @return
     */
    @ResponseBody
    @RequestMapping("/addBrand")
    private int addBrand(PurchaseCBrand brand){
        int i = purchase.addBrand(brand);
        return i;
    }

    /**
     * 跳转修改品牌页面
     * @param brand
     * @return
     */
    @ResponseBody
    @RequestMapping("/brandUpdate")
    private PurchaseCBrand selectbrandOne(PurchaseCBrand brand){
        PurchaseCBrand purchaseCBrand = purchase.selectbrandOne(brand);
        return purchaseCBrand;
    }

    /**
     * 修改某一品牌
     * @param brand
     * @return
     */
    @ResponseBody
    @RequestMapping("/updateBrand")
    private int updateBrand(PurchaseCBrand brand){
        int i = purchase.updateBrand(brand);
        return i;
    }
}
